package com.valuegroup.smarttodo.ui.programme.weekplan;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.valuegroup.smarttodo.R;
import com.valuegroup.smarttodo.data.DataManager;
import com.valuegroup.smarttodo.data.vo.TodoVo;
import com.valuegroup.smarttodo.ui.BaseActivity;
import com.valuegroup.smarttodo.ui.programme.goals.GoalsEventAdapter;

import net.cachapa.expandablelayout.ExpandableLayout;

import java.util.List;

import androidx.appcompat.widget.PopupMenu;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class WeekEventPoolActivity extends BaseActivity {
    PopupMenu filterMenu;
    private GoalsEventAdapter adapter;

    @BindView(R.id.imgbtn_back)
    ImageButton imgbtnBack;
    @BindView(R.id.labHeaderTitle)
    TextView headerTitle;
    @BindView(R.id.tv_add_btn)
    TextView tvAddBtn;

    @BindView(R.id.tagClear)
    ImageView tagClear;
    @BindView(R.id.btnClear)
    LinearLayout btnClear;
    @BindView(R.id.et_search)
    EditText etSearch;

    @BindView(R.id.btnExpand)
    LinearLayout btnExpand;
    @BindView(R.id.tagExpand)
    ImageView tagExpand;
    @BindView(R.id.expandable_layout)
    ExpandableLayout expandableLayout;

    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_week_event_pool);
        ButterKnife.bind(this);

        assert recyclerView != null;
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        List<TodoVo> data = DataManager.getTodoData();
        adapter = new GoalsEventAdapter(this, getWindow().getDecorView(), data);
        recyclerView.setAdapter(adapter);


        expandableLayout.setOnExpansionUpdateListener(new ExpandableLayout.OnExpansionUpdateListener() {
            @Override
            public void onExpansionUpdate(float expansionFraction, int state) {
            }
        });

    }

    @OnClick({R.id.imgbtn_back, R.id.tv_add_btn, R.id.btnExpand, R.id.btnClear})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.imgbtn_back:
                finishAfterTransition();
                break;
            case R.id.tv_add_btn:
                finishAfterTransition();
                break;
            case R.id.btnExpand:
                if (expandableLayout.isExpanded()) {
                    tagExpand.setImageResource(R.drawable.ic_expand_gray3);
                    expandableLayout.collapse();
                } else {
                    expandableLayout.expand();
                    tagExpand.setImageResource(R.drawable.ic_shrink_gray3);
                }
                break;
        }
    }


}